﻿
namespace n_GUIset
{
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using n_MainSystemData;

//图形和形状类
public static class GUIset
{
	public static bool UseOS = true;
	
	//软件名称
	public static string SoftLabel;
	
	//图形界面背景颜色和画刷
	public static Color myBackColor;
	public static Brush BackBrush;
	public static Pen BackPen;
	
	public static Brush BackBrushSim;
	public static Color myFreeAreaColor;
	public static Brush FreeAreaBrush;
	
	//标题栏颜色和窗体边框颜色
	public static Color FormColor;
	public static Brush FormBrush;
	
	//logo颜色
	public static Color HeadBackColor;
	public static Brush HeadBackBrush;
	
	//隐藏背景画刷
	public static Brush HideBackBrush;
	
	//中间对称文字显示格式
	public static StringFormat MidFormat;
	//左对齐文字显示格式
	public static StringFormat LeftFormat;
	//右对齐文字显示格式
	public static StringFormat RightFormat;
	
	//界面背景颜色
	public static Color GUIbackColor;
	
	//无线模块接口连接画笔
	public static Pen RF_Pen;
	//红外模块接口连接画笔
	public static Pen IR_Pen;
	//普通接口画笔
	public static Pen NOR_Pen;
	
	//表达式字体
	public static Font ExpFont;
	//变量仿真数据字体
	public static Font SimFont;
	//组件名称字体
	public static Font ModuleNameFont;
	//组件是否支持仿真字体
	public static Font ModuleSimNameFont;
	
	//Tip字体
	public static Font Font9;
	public static Font Font11;
	public static Font Font12;
	public static Font Font13;
	public static Font Font14;
	//Tip字体
	public static Font Font20;
	
	//调试字体
	public static Font DebugFont;
	
	//标题栏字体
	public static Font FormTextFont;
	//文件路径字体
	public static Font FileDirFont;
	
	//表达式最顶端词的边框画笔
	public static Pen WordPen;
	//表达式最顶端词的画刷
	public static Brush WordBrush;
	
	//用于调用图形化类的静态函数如字体尺寸等
	public static Graphics mg;
	
	//组件高亮的边框
	public static Pen 组件高亮边框_Pen1;
	public static Pen 组件高亮边框_Pen2;
	
	public static bool BlackHead = true;
	
	//初始化
	public static void Init()
	{
		//设置背景颜色
		//myBackColor = GetBlueColor( 50 );
		//myBackColor = GetBlueColor( 200 );
		//myBackColor = GetBlueColor( 180 );
		
		myBackColor = GUIbackColor;
		
		//myBackColor = Color.FromArgb( 70, 70, 70 );
		//myBackColor = Color.SlateGray;
		//myBackColor = Color.FromArgb(35, 46, 40);
		//myBackColor = Color.FromArgb(45, 65, 95);
		BackBrush = new SolidBrush( myBackColor );
		
		BackBrushSim = new SolidBrush( Color.FromArgb( 95, 90, 85 ) );
		
		//LogoColor = Color.FromArgb(60, 130, 210);
		HeadBackColor = SystemData.HeadMessageBackColor;
		HeadBackBrush = new SolidBrush( HeadBackColor );
		
		myFreeAreaColor = Color.FromArgb( 240, 240, 240 );
		FreeAreaBrush = new SolidBrush( myFreeAreaColor );
		
		if( SystemData.isBlack ) {
			FormColor = GetBlueColor( 80 );
		}
		else {
			//FormColor = GetBlueColor1( 200 );//90
			//FormColor = GetBlueColor2( 255 );//90
			
			FormColor = SystemData.FormColor;
		}
		//FormBrush = new SolidBrush( GetBlueColor( 180 ) );
		FormBrush = new SolidBrush( FormColor );
		BackPen = new Pen( FormColor );
		//BackPen = new Pen( Color.Black );
		
		ModuleNameFont = new Font( "微软雅黑", 10, FontStyle.Regular );
		ModuleSimNameFont = new Font( "微软雅黑", 9, FontStyle.Regular );
		
		DebugFont = new Font( "微软雅黑", 35, FontStyle.Bold );
		
		SimFont = new Font( "微软雅黑", 15, FontStyle.Regular );
		
		ExpFont = new Font( "微软雅黑", 10, FontStyle.Regular );
		FormTextFont = new Font( "微软雅黑", 12, FontStyle.Regular );
		FileDirFont = new Font( "微软雅黑", 12, FontStyle.Regular );
		
		Font9 = new Font( "微软雅黑", 9, FontStyle.Regular );
		Font11 = new Font( "微软雅黑", 11, FontStyle.Regular );
		Font12 = new Font( "微软雅黑", 12, FontStyle.Regular );
		Font13 = new Font( "微软雅黑", 13, FontStyle.Regular );
		Font14 = new Font( "微软雅黑", 14, FontStyle.Regular );
		Font20 = new Font( "微软雅黑", 20, FontStyle.Regular );
		
		WordPen = new Pen( Color.Blue, 1 );
		WordBrush = new SolidBrush( Color.FromArgb( 210, 210, 240 ) );
		
		mg = Graphics.FromHwnd( System.IntPtr.Zero );
		
		MidFormat = new StringFormat();
		MidFormat.Alignment = StringAlignment.Center;
		MidFormat.LineAlignment = StringAlignment.Center;
		
		LeftFormat = new StringFormat();
		LeftFormat.Alignment = StringAlignment.Near;
		LeftFormat.LineAlignment = StringAlignment.Center;
		
		RightFormat = new StringFormat();
		RightFormat.Alignment = StringAlignment.Far;
		RightFormat.LineAlignment = StringAlignment.Center;
		
		if( SystemData.isBlack ) {
			组件高亮边框_Pen1 = new Pen( Color.White, 1 );
		}
		else {
			组件高亮边框_Pen1 = new Pen( Color.LightSlateGray, 1 );
		}
		组件高亮边框_Pen2 = new Pen( Color.OrangeRed, 3 );
		
		HideBackBrush = new SolidBrush(
			Color.FromArgb(
				210,
			    GUIset.myBackColor.R,
			    GUIset.myBackColor.G,
			    GUIset.myBackColor.B
			    ) );
		
		System.Drawing.Drawing2D.AdjustableArrowCap AC = new AdjustableArrowCap( 3, 2, true );
		
		if( SystemData.isBlack ) {
			RF_Pen = new Pen( Color.FromArgb( 200, 0, 100, 255 ), 10 );
			RF_Pen.CustomEndCap = AC;
			IR_Pen = new Pen( Color.FromArgb( 200, 255, 100, 0 ), 10 );
			IR_Pen.CustomEndCap = AC;
			NOR_Pen = new Pen( Color.FromArgb( 150, 200, 200, 200 ), 7 );
		}
		else {
			RF_Pen = new Pen( Color.FromArgb( 150, 0, 100, 200 ), 10 );
			RF_Pen.CustomEndCap = AC;
			IR_Pen = new Pen( Color.FromArgb( 150, 200, 100, 0 ), 10 );
			IR_Pen.CustomEndCap = AC;
			NOR_Pen = new Pen( Color.FromArgb( 200, 120, 140, 160 ), 5 );
		}
		NOR_Pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
		NOR_Pen.CustomEndCap = AC;
	}
	
	//获取默认颜色
	public static Color GetBlueColor( int a )
	{
		//return Color.FromArgb( a*4/9, a*2/3, a );
		
		return Color.FromArgb( a*60/100, a*63/100, a*66/100 );
		
		//return Color.FromArgb( a*75/100, a*80/100, a*85/100 );
	}
	
	//获取默认颜色
	public static Color GetBlueColor1( int a )
	{
		//return Color.FromArgb( a*4/9, a*2/3, a );
		
		return Color.FromArgb( a*60/100, a*70/100, a*80/100 );
		
		//return Color.FromArgb( a*75/100, a*80/100, a*85/100 );
	}
	
	//获取默认颜色
	public static Color GetBlueColor2( int a )
	{
		//return Color.FromArgb( a*4/9, a*2/3, a );
		
		return Color.FromArgb( a*170/255, a*185/255, a*200/255 );
		
		//return Color.FromArgb( a, a, a );
	}
	
	//获取默认颜色
	public static Color GetRedColor( int a )
	{
		return Color.FromArgb( a, a*2/3, a*4/9 );
	}
}
}

